package com.intelligencesoft.pss.orm;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.intelligencesoft.pss.auth.LoginUtil;
import com.intelligencesoft.pss.entity.BasePojo;
import com.intelligencesoft.pss.entity.listeners.ModelHandler;

@Component
public class AutoUpdate implements ModelHandler{
	@Autowired
	private LoginUtil loginUtil;
	@Override
	public void prePersist(BasePojo model) {
		Object id = loginUtil.getLoginInfo("id");
		String createUser = id==null?"null":id.toString();
		model.setCreateUser(createUser);
		model.setCreateDate(new Date());
	}

	@Override
	public void preUpdate(BasePojo model) {
		
	}
}
